<?php
namespace app\repair\controller;
use think\Request;
use app\common\controller\Common;
class Ratio extends Common
{
	protected $afterActionList = [
        'addOperLog'  =>  ['only'=>'index'],
    ];
	/**
	* 维修提成设置
	*/
	public function index()
	{
		$row = model('Ratio')->where('shop_id',session('admin.shop_id'))->find();
		if(Request()->isGet()){
			$this->assign('row',$row);
			return $this->fetch('');
		}
		if(Request()->isAjax()){
			$data = Request()->param('');
			$model = $row ? $row : model('Ratio');
			$model->sale_ratio = $data['sale_ratio'];
			$model->repair_ratio = $data['repair_ratio'];
			$model->shop_id = session('admin.shop_id');
			$model->save();
			$this->log_id = $model->repair_config_id;
			$this->success(config('status.SUCCESS_ONE'));
		}
	}
}